<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="./template.xhtml">
    <ui:define name="head">
        <style type="text/css">
            .ui-row-editor .ui-row-editor-pencil {
                margin-left:8px;
            }

            .ui-editable-column .ui-cell-editor-input {
                overflow: hidden;
            }

            .ui-editable-column .ui-cell-editor-input * {
                box-sizing: border-box;
            }
        </style>
    </ui:define>
    
    <ui:define name="title">
        TreeTable - <span class="subitem">Edit</span>
    </ui:define>

    <ui:define name="description">
        Data displayed on treetable can be edited at row or cell level.
    </ui:define>

    <ui:param name="documentationLink" value="/components/treetable" />

    <ui:define name="implementation">

         <h:form id="form">
            <p:growl id="msgs" showDetail="true"/>

            <p:treeTable value="#{ttEditView.root}" editable="true" var="document" style="margin-bottom:20px">
                <f:facet name="header">
                    Row Editing
                </f:facet>
                
                <p:ajax event="rowEdit" listener="#{ttEditView.onRowEdit}" update=":form:msgs" />
                <p:ajax event="rowEditCancel" listener="#{ttEditView.onRowCancel}" update=":form:msgs" />

                <p:column headerText="Name"> 
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{document.name}" /></f:facet>
                        <f:facet name="input"><p:inputText value="#{document.name}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Size">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{document.size}" /></f:facet>
                        <f:facet name="input"><p:inputText value="#{document.size}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Type">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{document.type}" /></f:facet>
                        <f:facet name="input"><p:inputText value="#{document.type}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column style="width:32px">
                    <p:rowEditor />
                </p:column>
            </p:treeTable>

            <p:treeTable value="#{ttEditView.root2}" editable="true" editMode="cell" var="document">
                <f:facet name="header">
                    Cell Editing
                </f:facet>
                
                <p:ajax event="cellEdit" listener="#{ttEditView.onCellEdit}" update=":form:msgs" />

                <p:column headerText="Name"> 
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{document.name}" /></f:facet>
                        <f:facet name="input"><p:inputText value="#{document.name}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Size">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{document.size}" /></f:facet>
                        <f:facet name="input"><p:inputText value="#{document.size}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Type">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{document.type}" /></f:facet>
                        <f:facet name="input"><p:inputText value="#{document.type}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
            </p:treeTable>
         </h:form>
        
    </ui:define>

</ui:composition>